package com.atguigu.userprofile.dao;

import com.atguigu.userprofile.bean.TaskTagRule;
import com.atguigu.userprofile.utils.MySQLUtil;

import java.util.List;

public class TaskTagRuleDAO {
    public static List<TaskTagRule> getTaskTagRuleWithTaskId(String taskId) {

        String querySQL = "SELECT " +
                "tr.id," +
                "tr.tag_id," +
                "tr.task_id," +
                "tr.query_value," +
                "tr.sub_tag_id," +
                //注意！！！！ 查询出来的字段名字一定要符合JavaBean的命名方式 这样才能识别
                "ti.tag_name as sub_tag_value " +
                "FROM task_tag_rule tr\n" +
                "JOIN tag_info ti\n" +
                "ON tr.sub_tag_id=ti.id\n" +
                "WHERE task_id = " + taskId;

        List<TaskTagRule> tagRuleList = MySQLUtil.queryList(querySQL, TaskTagRule.class, true);
        return tagRuleList;
    }
}
